package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.wx.auth.bo.AuthBo;
import com.cskaoyan.service.wx.auth.AuthService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 创建日期: 2022/05/07 16:53
 *
 * @author JinLu Zhou
 */
@RestController
@RequestMapping("wx/auth")
@Controller("wxAuthController")
public class AuthController {
    @Autowired
    AuthService authService;

    @PostMapping("login")
    public BaseRespVo login(@RequestBody AuthBo authBo) {
        return authService.login(authBo);
    }

    @PostMapping("logout")
    public BaseRespVo logout() {
        Subject subject = SecurityUtils.getSubject();
        subject.logout();
        BaseRespVo baseRespVo = new BaseRespVo<>();
        baseRespVo.setErrmsg("成功");
        baseRespVo.setErrno(0);
        return baseRespVo;
    }
}
